﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace bordspil.Models
{
    public class GameService    // talk with Database // another comment
    {
        private static GameService _instance;        // we will always get one instance

        private Dictionary<int, Game> games;

        private GameService()
        {
            // stubb i staðinn fyrir DB á meðan.
            this.games = new Dictionary<int, Game>();

            Game g1 = new Game() { ID = 1, ViewName = "OlsenOlsen", GameName = "Olsen Olsen", Image = "http://allaboutcards.files.wordpress.com/2010/01/200px-playing_card_heart_8_svg_small.png?w=593" };
            Game g2 = new Game() { ID = 2, ViewName = "Connect4", GameName = "Tengdu 4", Image = "http://upload.wikimedia.org/wikipedia/en/a/a4/Connect_four_game.svg" };

            this.games[g1.ID] = g1;
            this.games[g2.ID] = g2;
        }

        public static GameService Instance
        {
            get
            {
                if (_instance == null)
                    _instance = new GameService();
                return _instance;
            }
        }

        public List<Game> GetGameEntries()  // will get data from database and return List of them
        {
            return this.games.Values.ToList();
        }

        public Game GetGameById(int id)     // will get game by wanted id
        {
            return this.games[id];
        }
    }
}